package db.util;

import task.DbTask.DbType;

public class DbTypeColumnComparator implements ColumnComparator {
	private DbType aType;
	private DbType bType;
	public DbTypeColumnComparator(DbType aType, DbType bType) {
		this.aType = aType;
		this.bType = bType;
	}
	@Override
	public boolean equals(Column a, Column b, StringTree report) {
		if (aType == bType) {
			return a.equals(b, report);
		}
		if (a.getDataType().toLowerCase().contains("varchar") && b.getDataType().toLowerCase().contains("varchar")) {
			return a.equalsIgnoreDataType(b, report);
		}
		if (aType == DbType.ORACLE) {
			if (a.getDataType().equals("CHAR") && b.getDataType().equals("bpchar")) {
				return a.equalsIgnoreDataType(b, report);
			}
		} else {
			if (b.getDataType().equals("CHAR") && a.getDataType().equals("bpchar")) {
				return a.equalsIgnoreDataType(b, report);
			}
		}
		return a.equals(b, report);
	}

}
